<template>
  <div class="searchplaylist">
    <div
      class="playlit-item"
      :class="backColor(index)"
      v-for="(item, index) in playlists"
      :key="index"
      @click="toPlaylistDetails(item.id)"
    >
      <div class="left-img-text">
        <div class="image">
          <img :src="item.coverImgUrl" alt="" />
        </div>
        <p>{{ item.name }}</p>
      </div>

      <div class="center-text">
        <span>{{ item.trackCount }}首</span>
      </div>
      <div class="right-text">
        <span>{{ item.creator.nickname }}</span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "searchlist",
  components: {},
  props: {
    playlists: {
      type: [Array, String, Object]
    }
  },
  data() {
    return {};
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {
    backColor(index) {
      if (index % 2 !== 0) {
        return "backColor";
      }
    },
    toPlaylistDetails(id) {
      this.$router.push({
        name: "playlistdetails",
        query: {
          id
        }
      });
    }
  }
};
</script>

<style scoped lang="scss">
.searchplaylist {
  margin-bottom: 30px;
}
.playlit-item {
  height: 80px;
  line-height: 80px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  color: #555555;
  padding: 10px 0;
  .left-img-text {
    width: 60%;
    display: flex;
    justify-content: flex-start;
    .image {
      height: 100%;
      width: 80px;
      img {
        width: 100%;
        height: 100%;
        border-radius: 5px;
      }
    }
    p {
      margin: 0 20px;
    }
  }
  .center-text {
    width: 20%;
    span {
      font-size: 14px;
      color: #a2a2a2;
      cursor: pointer;
    }
  }
  .right-text {
    width: 40%;
    span {
      font-size: 14px;
      color: #6f6f6f;
      cursor: pointer;
    }
  }
  &:hover {
    background: #f5f7fa;
  }
}
.backColor {
  background: #fafafa;
}
</style>
